home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: uu4news.netcom.com!zodiac!szh
- From: szh@zcon.com (Syed Zaeem Hosain)
- Subject: Re: Help:what is wrong this code?
- Message-ID: <1996Apr10.160601.21676@zcon.com>
- Sender: szh@zcon.com (Syed Zaeem Hosain)
- Nntp-Posting-Host: zodiac
- Reply-To: szh@zcon.com
- Organization: Z Consulting Group
- References: <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
- Date: Wed, 10 Apr 1996 16:06:01 GMT
-
- In article <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>, Norma Mathews <n9341884@henson.cc.wwu.edu> writes:
- >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
- >>
- >>
- >> >Why it give me 0.0000?
- >>
- >> >#include <stdio.h>
- >> >main () {
- >> >double a=9.008;
- >> >printf("%f\n",sqrt(a));
- >> >return 0;
- >> >}
- >
- >your printf specifer needs to be "%lf", not "%f", since a is a double
-
- No, not correct! Please see question 14.2 in the comp.lang.c FAQ.
-
- Please look at the FAQ and refer to the answers to questions like the
- following (note questiona 12.9 and 15.2, which show that your answer
- is not correct:
-
- 12.9: Someone told me it was wrong to use %lf with printf(). How can
- printf() use %f for type double, if scanf() requires %lf?
-
- 12.13: Why doesn't this code:
-
- double d;
- scanf("%f", &d);
-
- work?
-
- 14.2: I'm trying to take some square roots, but I'm getting crazy
- numbers.
-
- 15.2: How can %f be used for both float and double arguments in
- printf()? Aren't they different types?
-
- The FAQ can be found at rtfm.mit.edu:/pub/usenet/comp.lang.c/
-
- Z
-
-
- --
- -------------------------------------------------------------------------
- | Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 |
- | Z Consulting Group San Jose, CA 95161 szh@zcon.com |
- -------------------------------------------------------------------------
-